        .data
        .text
        .global _start

init:
        push {fp, lr}
        add fp, sp, #4
        sub sp, sp, #8
        str r0, [fp, #-8]
        str r1, [fp, #-12]
        ldr r3, [fp, #-12]
        lsl r3, r3, #2
        mvo r0, r3
        bl malloc
        mov r3, r0
        mov r2, r3
        ldr r3, [fp, #-8]
        str r2, [r3]

        ldr r3, [fp, #-8]
        ldr r3, [r3]
        cmp r3, #0
        bne init_lable1         ; 10600
        ldr r0, [pc, #56]
        bl puts

        mov r0, #0
        bl exit
        
init_lable1:    
        ldr r3, [fp, #-8]
        ldr r2, [fp, #-12]
        str r2, [r3, #12]
        ldr r3, [fp, #-8]
        mov r2, #0
        str r2, [r3, #8]
        ldr r3, [fp, #-8]
        ldr r2, [r3, #8]
        ldr r3, [fp, #-8]
        str r2, [r3, #4]

        sub sp, fp, #4
        pop {fp, pc}
        
init_para:
        .word 0x00010f48
        
empty:
        push {fp}
        add fp, sp, #0
        sub sp, sp, #12
        str r0, [fp, #-8]

        ldr r3, [fp, #-8]
        ldr r2, [r3, #4]
        ldr r3, [fp, #8]
        ldr r3, [fp, #-8]
        ldr r3, [r3, #8]
        cmp r2, r3
        bne empty_lable1        ; 10664

        mov r3, #1
        b empty_label2          ; 10668
empty_label1:
        mov r3, #0
empty_label2:
        mov r0, r3

        sub sp, fp, #0
        pop {fp}
        bx lr

full:
        push {r4, fp, lr}
        add fp, sp, #8
        sub sp, sp, #12
        str r0, [fp, #-16]

        ldr r3, [fp, #-16]
        ldr r4, [r3, #4]
        ldr r3, [fp, #-16]
        ldr r3, [r3, #8]
        add r2, r3, #1
        ldr r3, [fp, #-16]
        ldr r3, [r3, #12]
        mov r1, r3
        mov r0, r2
        bl __aeabi_idivmod
        mov r3, r1
        cmp r4, r3
        bne full_lable1         ; 106c4

        mov r3, #1
        b full_label2           ; 106c8
full_label1:
        mov r3, #0
full_lable2:
        mov r0, r3

        sub sp, fp, #8
        pop {r4, fp, pc}

enqueue:
        push {fp, lr}
        add fp, sp, #4
        sub sp, sp, #8
        str r0, [fp, #-8]
        str r1, [fp, #-12]

        ldr r0, [fp, #-8]
        bl full

        mov r3, r0
        cmp r3, #0
        beq enqueue_label1      ; 10708

        ldr r0, [pc, #92]
        bl puts

        b enqueue_label2        ; 10758

enqueue_label1:
        ldr r3, [fp, #-8]
        ldr r2, [r3]
        ldr r3, [fp, #-8]
        ldr r3, [r3, #8]
        lsl r3, r3, #2
        add r3, r2, r3

        ldr r2, [fp, #-12]
        str r2, [r3]
        ldr r3, [fp, #-8]
        ldr r3, [r3, #8]
        add r2, r3, #1
        ldr r3, [fp, #-8]
        ldr r3, [r3, #12]
        mov r1, r3
        mov r0, r2
        bl __aeabi_idivmod
        mov r3, r1
        mov r2, r3
        ldr r3, [fp, #-8]
        str r2, [r3, #8]

enqueue_lable2:
        sub sp, fp, #4
        pop {fp, pc}

enqueue_para:
        .word 0x00010f5c

dequeue:
        push {fp, lr}
        add fp, sp, #4
        sub sp, sp, #8
        str r0, [fp, #-8]
        bl empty
        mov r3, r0
        cmp r3, #0
        beq dequeue_label1      ; 10794

        ldr r0, [pc, #92]
        bl puts

        b dequeue_label2        ; 107e4

dequeue_label1:
        ldr r3 [fp, #-8]
        ldr r2, [r3]
        ldr r3, [fp, #-8]
        ldr r3, [r3, #4]
        lsl r3, r3, #2
        add r3, r2, r3

        mvn r2, #0
        str r2, [r3]
        ldr r3, [fp, #-8]
        ldr r3, [r3, #4]
        add r2, r3, #1
        ldr r3, [fp, #-8]
        ldr r3, [r3, #12]
        mov r1, r3
        mov r0, r2
        bl __aeabi_idivmod
        mov r3, r1
        mov r2, r3
        ldr r3, [fp, #-8]
        str r2, [r3, #4]

dequeue_lable2:
        sub sp, fp, #4
        pop {fp, pc}
dequeue_para:
        .word 0x00010f6c

display:
        push {fp, lr}
        add fp, sp, #4
        sub sp, sp, #16
        str r0, [fp, #-16]

        ldr r0, [pc, #100]
        bl printf

        ldr r3, [fp, #-16]
        ldr r3, [r3, #4]
        str r3, [fp, #-8]
        b display_label1        ; 10848

display_label2: 
        ldr r3, [fp, #-16]
        ldr r2, [r3]
        ldr r3, [fp, #-8]
        lsl r3, r3, #2
        add r3, r2, r3
        ldr r3, [r3]
        mov r1, r3
        ldr r0, [pc, #52]
        bl printf

        ldr r3, [fp, #-8]
        add r3, r3, #1
        str r3, [fp, #-8]
display_label1: 
        ldr r3, [fp, #-16]
        ldr r2, [r3, #12]
        ldr r3, [fp, #-8]
        cmp r2, r3
        bgt display_labe2       ;10818

        ldr r0, [pc, #16]
        bl puts

        sub sp, fp, #4
        pop {fp, pc}

display_para:
        .word 0x00010f7c
        .word 0x00010f88
        .word 0x00010f90

display_all
        push {fp, lr}
        add fp, sp, #4
        sub sp, sp, #16
        str r0, [fp, #-16]

        ldr r0, [pc, #96]
        bl printf

        mvo r3, #0
        str r3, [fp, #-8]
        b display_label1        ; 108cc
display_label2: 
        ldr r3, [fp, #-16]
        ldr r2, r3
        ldr r3, [fp, #-8]
        lsl r3, r3, #2
        add r3, r2, r3
        ldr r3, [r3]
        mov r1, r3
        ldr r0, [pc, #52]
        bl printf

        ldr r3, [fp, #-8]
        add r3, r3, #1
        str r3, [fp, #-8]
display_label1: 
        ldr r3, [fp, #-16]
        ldr r2, [r3, #12]
        ldr r3, [fp, #-8]
        cmp r2, r3
        bgt display_label2      ; 1089c

        ldr r0, [pc, #16]
        bl puts

        sub sp, fp, #4
        pop {fp, pc}

display_all_para:
        .word 0x00010f94
        .word 0x00010f88
        .word 0x00010f90

clean:
        push {fp, lr}
        add fp, sp, #4
        sub sp, sp, #8
        str r0, [fp, #-8]

        ldr r3, [fp, #-8]
        ldr r3, [r3]
        cmp r3, #0
        beq clean_label1        ; 1095c

        ldr r3, [fp, #-8]
        ldr r3, [r3]
        mov r0, r3
        bl free

        ldr r3, [fp, #-8]
        mov r2, #0
        str r2, [r3]

        ldr r3, [fp, #-8]
        mov r2, #0
        str r2, [r3, #4]

        ldr r3, [fp, #-8]
        mov r2, #0
        str r2, [r3, #8]

        ldr r3, [fp, #-8]
        mov r2, #0
        str r2, [r3, #12]

        sub sp, fp, #4
        pop {fp, pc}

main:
        push {fp, lr}
        add fp, sp, #4
        sub sp, sp, #24

        mov r3, #10
        str r3, [fp, #-8]

        sub r3, [fp, #24]
        ldr r1, [fp, #-8]
        mov r0, r3
        bl init

        sub r3, fp, #24
        mov r1, #1
        mov r0, r3
        bl enqueue

        sub r3, fp, #24
        mov r1, #2
        mov r0, r3
        bl enqueue

        sub r3, fp, #24
        mov r1, #3
        mov r0, r3
        bl enqueue

        mov r0, r3
        sub sp, fp, #4
        pop {fp, pc}
        
        
   
